#pragma once
#include <cstdint>
#include <ctime>
namespace myFs {
namespace basic {
using size_t = uint32_t;
#pragma pack(1)
struct Block {
    static size_t const BLOCK_SIZE = 1024;  ///< 1KB
    char                data[BLOCK_SIZE];
};

struct Inode {
    static size_t const REG_FILE     = 0;
    static size_t const DIR_FILE     = 1;
    static size_t const MAX_ADDR_NUM = 10;
    size_t              nlink;
    size_t              size;
    size_t              mode;
    size_t              uid;
    size_t              gid;
    size_t              addr[MAX_ADDR_NUM];
    //三个时间相关
    struct timespec atim;  //获取时间
    struct timespec mtim;  //修改时间
    struct timespec ctim;  //创建时间
};

struct Meta {
    static uint64_t const MAGIC_NUM = 0x1234567890123456;

    uint64_t magicNum = MAGIC_NUM;

    size_t inodeBitmapOffset = 0;
    size_t inodeBlockNum     = 1024 * 8;  //
    size_t inodeSpaceOffset  = 0;
    size_t inodeSize         = sizeof(Inode);

    size_t blockBitmapOffset = sizeof(Meta);
    size_t blockBlockNum     = 1024 * 64;
    size_t blockSpaceOffset  = 0;
    size_t blockSize         = sizeof(Block);

    size_t rootInum = 0;

    bool isFormated() const {
        // return false;
        return magicNum == MAGIC_NUM;
    }
};

struct DirEntry {
    char   name[32];
    size_t inum;
};
#pragma pack()
}  // namespace basic
}  // namespace myFs